import Service from './core/service'; // 用于发送请求和处理model层逻辑
import Utils from './utils'; // 工具类
import Event from './core/event';   // 事件通知
import hooks from './core/hook';      // 钩子
import WebBridge from './web-bridge';      // 钩子
const Config = require(`@/config/${process.env.ENV_CONFIG || 'pro'}.config.json`);
const proto = {
  $utils: Utils,
  $event: Event,
  $hook: hooks,
  $webBridge: WebBridge,
  $configs: Config
};

export default {
  install: function (vue, options) {

    if (options.hooks) {
      Object.keys(options.hooks).forEach(v => {
        hooks.on(v, options.hooks[v])
      })
    }

    Object.assign(vue.prototype, proto); // 把各种功能赋予vue实例

    vue.mixin(require('./mixins/event').default);
    vue.mixin(require('./mixins/user-info').default);
  }
};

export {
  Utils,
  Service,
  Event,
  Config,
  WebBridge
};

Object.assign(window, {
  Utils,
  Service,
  Event,
  Config,
  WebBridge
});

